﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Text;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using webapp4U.BOL;

namespace webapp4U.UI
{
    public partial class Error : System.Web.UI.Page
    {
        public string strThongtin = "";
        string strRequest = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            strRequest = Request.QueryString["error"];

            lblThongTin.Text = strRequest;

            // goi email cho admin website
            SendMail sendmail = new SendMail();
            sendmail.MailServer = ConfigurationManager.AppSettings["SmtpServer"].ToString();
            sendmail.MailFrom = ConfigurationManager.AppSettings["EmailFrom"].ToString();
            sendmail.MailTo = ConfigurationManager.AppSettings["EmailWebmaster"].ToString();
            sendmail.Subject = "Co loi xay ra tu website: " +
                ConfigurationManager.AppSettings["Domain"].ToString();

            // noi dung can goi
            StringBuilder strBody = new StringBuilder(string.Empty);
            strBody.AppendLine("<br>");
            strBody.Append("<br> Thong tin loi : " + Server.GetLastError());
            strBody.Append("<br><br> Url : " + Globals.GetStringFromQueryString("aspxerrorpath"));
            
            sendmail.Body = strBody.ToString();


            SendMail.Send(sendmail);
        }
    }
}